<?php
include_once('include/Config.php');

class ProvinciaDAL{

    private $link;

    function __construct() {
        $this->conectar();
    }
    
    private function conectar() {
        
        //Tomado del config.php 
        $this->link = $GLOBALS["DBConnPDO"];
        
    }    
    
    function comboProvincia(){
        $query = "SELECT idProvincia, Descripcion FROM provincia";
        
        $result = '';
        
        foreach ($this->link->query($query) as $row) {
            $result .= $row['idProvincia'].':'.$row['Descripcion'].';';
        }
        
        if($result != null || $result != ''){
            $result = trim($result, ';');
        }
        
        return $result;
    }
    
    function comboProvinciaHTML(){
        $query = "SELECT idProvincia, Descripcion FROM provincia";
        
        $result = '';
        
        foreach ($this->link->query($query) as $row) {
            $result .= '<OPTION VALUE="' . $row['idProvincia'] . '">' . $row['Descripcion'] . '</OPTION>';
        }
        
        return $result;
    }    
}

?>
